package plug_in_javafx_dt.wizards;



import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class JFXWizardPage extends WizardPage{
	
	private static final String PAGE_NAME = "page 1 ",
			TITLE = "Create a new JavaFX Project",
			IMAGE_DESCRIPTOR="Enter a project name";
	
	private Composite container;
		
	private Text tProjectName, tLocation;

	
	public JFXWizardPage() {
		super(PAGE_NAME);
		setTitle(TITLE);
		setDescription(IMAGE_DESCRIPTOR);
		
	}
	
	@Override
	public void createControl(Composite parent) {
		container = new Composite(parent, SWT.NULL);
		GridLayout layout = new GridLayout(2,false);
		container.setLayout(layout);
		
		Label lPName = new Label(container, NONE);
		lPName.setText("name of project");
		
	    tProjectName = new Text(container, SWT.RIGHT);
		tProjectName.setText("");
		tProjectName.addKeyListener( new KeyListener() {
			
			@Override
			public void keyReleased(KeyEvent e) {
				if(!tProjectName.getText().isEmpty()){
					setPageComplete(true);
				}
				
			}
			
			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		
		Label lLocation = new Label(container, NONE);
		lLocation.setText("location");
		
	    tLocation = new Text(container, SWT.RIGHT);
		tLocation.setText("");
		tLocation.addKeyListener( new KeyListener() {
			
			@Override
			public void keyReleased(KeyEvent e) {
				if(!tProjectName.getText().isEmpty()){
					setPageComplete(true);
				}
				
			}
			
			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		
		
		setControl(container);
		setPageComplete(false);
		
	}

	public String getProjectName() {
		return tProjectName.getText();		
	}
	
	public String getLocation() {
		return tLocation.getText();		
	}
}
